#include <dolphin/socket.h>
typedef struct SOAddrInfo SOAddrInfo;
struct SOAddrInfo
{
int flags; // input flags
int family; // address family of socket
int sockType; // socket type
int protocol; // protocol of socket
unsigned addrLen; // length of socket address
char* canonName; // canonical name of service location
void* addr; // socket address of socket
SOAddrInfo* next; // pointer to next in list
};
// SOAddrInfo{}.flags
#define SO_AI_PASSIVE 0x01
#define SO_AI_CANONNAME 0x02
#define SO_AI_NUMERICHOST 0x04
#define SO_AI_NUMERICSERV 0x08
#define SO_EAI_AGAIN -300
#define SO_EAI_BADFLAGS -301
#define SO_EAI_FAIL -302
#define SO_EAI_FAMILY -303
#define SO_EAI_MEMORY -304
#define SO_EAI_NONAME -305
#define SO_EAI_SERVICE -306
#define SO_EAI_SOCKTYPE -307
#define SO_EAI_SYSTEM -308
#define SO_EAI_OVERFLOW -309
int SOGetAddrInfo( const char* nodeName, const char* servName,
const SOAddrInfo* hints, SOAddrInfo** res );
SOGetAddrInfo() translates a node name and/or a service name to
a set of socket addresses. SOGetAddrInfo() is thread-safe.
nodeName |
Pointer to an address string or NULL. Valid name is either a host name
or a dotted notation of an address. If nodeName
is NULL, SOGetAddrInfo() locates the service of the local host. |
||||||||||||||||
servName |
Pointer to a string specifying a decimal port number or NULL. If
servName is NULL, SOGetAddrInfo() returns
an IP address for the specified nodeName. |
||||||||||||||||
hints |
Pointer to a SOAddrInfo structure or NULL. If
hints is not NULL, every structure member other than
flags,
family, sockType, and protocol should be
zero-cleared before the function call.
|
||||||||||||||||
res
|
Upon successful completion, res refers to the
head of of a linked list of SOAddrInfo structure. Each
SOAddrInfo structure has the following fields:
The retrieved linked list no longer in use must be freed with |
| zero | Succeeded. |
SO_EAI_AGAIN
|
Name could not be resolved. Future attempt may succeed. |
SO_EAI_BADFLAGS
|
Specified flags is invalid. |
SO_EAI_FAIL
|
A non-recoverable error occurred. |
SO_EAI_FAMILY
|
Unknown address family. |
SO_EAI_MEMORY
|
Memory allocation failure. SOGetAddrInfo() invokes SOConfig{}.alloc
function to construct the linked list of SOAddrInfo structures
that is passed to res. |
SO_EAI_NONAME
|
Name could not be resolved. |
SO_EAI_SERVICE
|
Unknown service name. |
SO_EAI_SOCKTYPE
|
Unknown socket type. |
SO_EAI_SYSTEM
|
A system error occurred. |